<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2020/4/15
 * Time: 9:30
 */

namespace app\api\controller;


use think\Db;

class Tang extends Base
{
    private $user_id; // 用户ID
    private $page; // 页码
    private $create_time;
    
    /**
     * 异地登录验证
     * @return string
     */
    public function __construct()
    {
        $this->user_id = input('user_id');
        $this->page = input('page') ? input('page') : 1;
        $this->create_time = date('Y-m-d H:i:s');
        $time = input('time');
        $value = input('value');
        $reqKey = input('reqKey');
        $auth = $this->checkAll($this->user_id,$time,$value,$reqKey);
        if($auth == 112){
            echo json_encode(['status'=>301,'msg'=>$this->otherLogin]);
            exit;
        }elseif($auth == 110){
            echo json_encode(['status' => 302, 'msg' => $this->frost]);
            exit;
        }elseif($auth == 2111){
            echo json_encode(['status' => 303, 'msg' => $this->del]);
            exit;
        }
    }
    
    /**
     * 更改状态
     */
    public function openVideo(){
        $uid = input('uid');
        $status = input('status');
        Db::table('up_u_user')
            ->where('user_id', $uid)
            ->setField('user_open_video',$status);
        return json(['status' => 200, 'msg' => 'ok']);
    }
    /**
     * 获取某个人的状态
     */
    public function getOneopenVideo(){
        $uid = input('uid');
        $user_id = input('user_id');
        $one = Db::table('up_u_user')
            ->where('user_id', $uid)
            ->value('user_open_video');
        $two = Db::table('up_u_user')
            ->where('user_id', $user_id)
            ->value('user_open_video');
        $res = 1;
        if($one == 2 && $two == 2){
            $res = 2;
        }
        return json(['status' => 200, 'msg' => $res]);
    }

}